<?php
$sanitize_all_escapes = true;
$fake_register_globals = false;
$ignoreAuth = true;

require_once("../../interface/globals.php");
require_once("../../library/sql.inc");
require_once("../../library/formdata.inc.php"); 

$q = formData("q","G",true);
if (!$q) return;
$limit = $_GET['limit'];

$sql =  " SELECT * " .
        " FROM drugs d, drugs_qnt dq " .
        " where lower(d.name) like ('".$q."%')  AND d.drug_id = dq.drug_id " .
        " order by name " .
        " limit  ".$limit;

//echo $sql;

$rez = sqlStatement($sql);

while ($row = sqlFetchArray($rez)) {
    echo $row['name'] . "(" . $row['unidad_referencia'] .", ".$row['cantidad']." ".$row['unidad'].") |" . $row['drug_id'] . "\n";
}
?>